package com.cisetech.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cisetech.mapper.bobocai.LBannerMapper;
import com.cisetech.service.AdvService;
import com.cisetech.vo.Page;
import com.cisetech.vo.bobocai.LBanner;

@Service
public class AdvServiceImpl implements AdvService {
	
	@Autowired
	LBannerMapper bannerMapper;
	
	
	@Override
	public int insertAdv(LBanner banner) {
		if(banner.getId()!=null && banner.getId()!=0){
			return bannerMapper.UpdateAdv(banner);
		}
		return bannerMapper.insertAdv(banner);
	}


	@Override
	public Page<LBanner> getListAdv(LBanner banner) {
		Page<LBanner> page = new Page<LBanner>();
		if(banner!=null && banner.getPageNo()>0){
			banner.setCalculationPge((banner.getPageNo()-1)*banner.getPageSize());
		}
		List<LBanner> list = bannerMapper.getListAdv(banner);
		Integer i = bannerMapper.findListCountAdv();
		page.Pagehtml(banner.getPageNo(), banner.getPageSize(), i, list);
		return page;//list==null ? new ArrayList<LContent>() : list;
	}
	//查询一共有多少条
	@Override
	public Integer findListCountAdv() {
		Integer i = bannerMapper.findListCountAdv();
		return i;
	}
	@Override
	public int deleteAdv(String id) {
		try {
			bannerMapper.deleteAdv(id);
			return 0;
		} catch (Exception e) {
			return 1;
		}
	}
	/*@Override
	public int UpdateAdv(LBanner banner) {
		try {
			bannerMapper.UpdateAdv(banner);
			return 0;
		} catch (Exception e) {
			return 1;
		}
	}*/
	@Override
	public List<LBanner> FindListByAdv(LBanner banner) {
		return bannerMapper.FindListByAdv(banner);
	}
}
